import request from '@/config/axios'

// 行业类目 VO
export interface ShopCategoryVO {
  id: number | string // 唯一编号
  name: string // 分类名称
  code: string // 分类编码
  sort: number // 分类排序
  status: number // 开启状态
}

// 行业类目 API
export const ShopCategoryApi = {
  // 查询行业类目分页
  getShopCategoryPage: async (params: any) => {
    return await request.get({ url: `/shop/category/page`, params })
  },
  getShopCategoryList: async (params: any) => {
    return await request.get({ url: `/shop/category/list`, params })
  },

  // 查询行业类目列表
  getShopCategorySimpleList: async (shopId: number | string | undefined) => {
    if (shopId) {
      return await request.get({ url: `/shop/category/simple-list?shopId=` + shopId })
    }
    return await request.get({ url: `/shop/category/simple-list` })
  },

  // 查询行业类目详情
  getShopCategory: async (id: number | string) => {
    return await request.get({ url: `/shop/category/get?id=` + id })
  },

  // 新增行业类目
  createShopCategory: async (data: ShopCategoryVO) => {
    return await request.post({ url: `/shop/category/create`, data })
  },

  // 修改行业类目
  updateShopCategory: async (data: ShopCategoryVO) => {
    return await request.post({ url: `/shop/category/update`, data })
  },

  // 删除行业类目
  deleteShopCategory: async (id: number | string) => {
    return await request.get({ url: `/shop/category/delete?id=` + id })
  },

  // 导出行业类目 Excel
  exportShopCategory: async (params) => {
    return await request.download({ url: `/shop/category/export-excel`, params })
  }
}
